package game.entity.item;

import edu.monash.fit2099.engine.*;
import game.entity.action.EatAction;

import java.util.ArrayList;
import java.util.List;

public class Fruit extends Item {

    private int age = 1;
    public boolean isOnGround = false;

    public Fruit() {
        this("fruit");
    }

    public Fruit(String name) {
        super(name, 'f', true);
    }

    public Fruit(String name, boolean isOnGround) {
        this(name);
        this.isOnGround = isOnGround;
    }

    @Override
    public List<Action> getAllowableActions() {
        ArrayList<Action> actions = new ArrayList<>();
        actions.add(new EatAction(this));
        return actions;
    }

    @Override
    public boolean canFeed() {
        return true;
    }

    @Override
    public int getHealPoints() {
        return 20;
    }

    @Override
    public void tick(Location currentLocation) {
//        水果在地上 15回合后腐烂 玩家库存中的水果不会腐烂
        if(isOnGround && age == 15){
            currentLocation.removeItem(this);
        }
        age++;
    }

    @Override
    public int getsoldPoints() {
        return 30;
    }
}
